var assert = require("assert")
var _ = require("rosa/html4")

var $ = exports

$.testBasic = function() {
	var t = _.div({"class":"CLASS"}, "Some text")
	assert.equal( "div", t.name )
	assert.equal( "CLASS", t.attrs["class"])
	assert.equal( 1, t.elems.length )
	assert.equal( "Some text", t.elems[0] )
}

$.testSkipAttrs = function() {
	var t = _.div(["Some text"])
	assert.equal( "div", t.name )
	assert.ok( !t.attrs )
	assert.ok( "Some text", t.elems[0] )
}

$.testMultipleParams = function() {
	var t = _.div( _.span("SPAN"), "TEXT", _.img({src:"SRC"}))
	assert.equal( "div", t.name )
	assert.ok( !t.attrs )
	assert.equal( "span", t.elems[0].name )
	assert.equal( "TEXT", t.elems[1] )
	assert.equal( "img", t.elems[2].name )
	assert.equal(3, t.elems.length)
}

$.testNoParams = function() {
	var t = _.br()
	assert.equal( "br", t.name )
	assert.ok( !t.attrs )
}

if (require.env === "rhino") {
	$.testJavaStrings = function() {
		var t = _.div({id:new java.lang.String("ID")}, new java.lang.String("CONTENT"))
		assert.equal( "div", t.name )
		assert.equal( "CONTENT", t.elems[0] )
		assert.equal( "ID", t.attrs.id )
	}
}